// PartialObjectPropByKeys
// 把一个索引类型的某些 Key 转为 可选的，其余的 Key 不变

interface Dong {
  name: string;
  age: number;
  address: string;
}

type PickRes = Pick<Dong, 'name' | 'age'>;

type OmitRes = Omit<Dong, 'name' | 'age'>;

type res = Partial<PickRes> & OmitRes;

type Copy<T> = {
  [K in keyof T]: T[K];
};

type res2 = Copy<res>;

type PartialObjectPropByKeys<T extends Record<string, any>, K extends keyof any> = Partial<
  Pick<T, Extract<keyof T, K>>
> &
  Omit<T, K>;

{
  type res = PartialObjectPropByKeys<Dong, 'name' | 'age'>;

  type res2 = Copy<res>;
}

{
  // 这样也是可以的
  type PartialObjectPropByKeys<T extends Record<string, any>, K extends keyof T> = Partial<
    Pick<T, K>
  > &
    Omit<T, K>;

  type res = PartialObjectPropByKeys<Dong, 'name' | 'age'>;

  type res2 = Copy<res>;
}
